<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@taglib uri="/WEB-INF/el.tld" prefix="el"%>
<%@taglib uri="/WEB-INF/fn.tld" prefix="fn"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title></title>
		<c:import url="/includes/css_inc.jsp"/>
		<c:import url="/includes/js_inc.jsp"/>
		<script>
			$(function(){
				$("#save").button({
		            icons: {
		                primary: "ui-icon-disk"
		            }
				}).click(function(){
					$("#job").val("editVenderType");
					$("#saveForm").submit();
				});
				$("#back").button({
		            icons: {
		                primary: "ui-icon-arrowreturnthick-1-w"
		            }
				}).click(function(){
					$("#job").val("back");
					$("#saveForm").submit();
				});
				$("#search").button({
		            icons: {
		                primary: "ui-icon-search"
		            }
				}).click(function(){
					if (validateEmpty()){
						$("#job").val("getVenderByProvinceId");
						$("#saveForm").submit();
					}
				});
				
			});
			function isChecked(id){
				if(document.getElementById(id).value == "Y"){
					document.getElementById(id).value = "N";
				}else{
					document.getElementById(id).value = "Y";
				}
			}
		</script>
	</head>
	<body>
		<c:set var="auth" value="${el:getMapValue(menuAuth, 'ACC60107')}"/>
		<c:import url="/apps/msg.jsp"/>
		<form class="acc67-form" name="saveForm" id="saveForm" action="${pageContext.request.contextPath}/acc6" method="post">
		<input type="hidden" name="app" id="app" value="ACC60107"/>
		<input type="hidden" name="job" id="job" value="${job}"/>
			<table width="100%" class="ui-widget ui-widget-content" border="0">
				<tr>
					<th align="left" class="acc67-header ui-widget-header" colspan="3"><b>${screenCode.ACC60107}</b></th>
				</tr>
				<tr>
				<td width="20%" class="bold">จังหวัด : </td>
				<td>
					<c:if test="${userInfo.areaLevel =='3'}">
						<c:forEach var="data" items="${userInfo.listUserProvice}">
							${data.provinceName}
							<input type="hidden" name="provinceId" id="provinceId" value="${data.provinceId}">
						</c:forEach>
					</c:if>
					<c:if test="${userInfo.areaLevel=='1' || userInfo.areaLevel=='2'}">
						<select name="provinceId" id="provinceId">
							<option value="">----- เลือก -----</option>
							<c:forEach var="data" items="${userInfo.listUserProvice}">
								<c:if test="${data.provinceId == provinceId}" var="provinceSeleted"/>
								<option value="${data.provinceId}" ${provinceSeleted?'selected':''}>${data.provinceName}</option>
							</c:forEach>
						</select>
					<span id="$provinceId" class="red">*</span>
					</c:if>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<c:if test="${fn:contains(auth, 'S')}">
						<button type="button" name="search" id="search" class="acc67-button"> ค้นหาข้อมูล </button>
					</c:if>
				</td>
			</tr>
			</table>
			<c:if test="${!empty listVender}">
			<br/>
			<table width="100%" class="ui-widget ui-widget-content" border="0">
				<tr>
					<th align="center" class="acc67-header ui-state-default" width="5%">สสอ</th>
					<th align="center" class="acc67-header ui-state-default">ชื่อหน่วยบริการ/คู่สัญญา</th>
					<th align="center" class="acc67-header ui-state-default">เลขบัญชี</th>
				</tr>
				<c:forEach items="${listVender}" var="data" varStatus="x">
					<c:if test="${data.venderType == 'A'}" var="isChecked"/>
					<tr  class="grid-tr-${x.count % 2}">
						<td align="center">
							<input type="checkbox" name="publicHealth" id="publicHealth" ${isChecked?'checked':''} onclick="isChecked('isCheck${x.count}');"/>
							<input type="hidden" name="venderCode" id="venderCode" value="${data.venderCode}"/>
							<%-- <input type="hidden" name="venderType" id="venderType" value="${data.venderType}"/> --%>
							<input type="hidden" name="venderAccount" id="venderAccount" value="${el:accountNoFormat(data.venderAccount)}"/>
							<input type="hidden" name="isCheck" id="isCheck${x.count}" value="${isChecked?'Y':'N'}"/>
						</td>
						<td align="left">${data.venderName}</td>
						<td align="center">${data.venderAccount}</td>
					</tr>
				</c:forEach>
				<tr>
					<td colspan="3" align="center">
						<c:if test="${fn:contains(auth, 'I') || fn:contains(auth, 'U')}">
							<button type="button" name="save" id="save" class="acc67-button"> บันทึก </button>
						</c:if>
						<button type="button" name="back" id="back" class="acc67-button"> ย้อนกลับ </button>
					</td>
				</tr>
			</table>
		</c:if>
		</form>
	</body>
</html>